package util;

import java.util.ResourceBundle;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class DAO_Util {

	private static EntityManagerFactory emFactory;

	private static EntityManager em;

	public static EntityManagerFactory getEMF() {
		if (emFactory == null) {
			//emFactory = Persistence.createEntityManagerFactory("Twitter");
			emFactory = Persistence.createEntityManagerFactory(ResourceBundle.getBundle("mensagens_pt_BR").getString("persistenceName"));
		}
		return emFactory;
	}

	public static EntityManager getEM() {
		if (em == null) {
			getEMF();
			em = emFactory.createEntityManager();
		}
		return em;
	}

}
